package puyu.manage.service.utils;


import com.google.common.base.CaseFormat;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.MapWrapper;

import java.util.Map;

/**
 *  @ClassName: 重写map的包装器将Map的key全部转换驼峰命名
 *  @author: whl
 *  @Date: 2024/6/8 10:41
 *  @Description: Description of this class
 */
public class MapKeyUpperWrapper extends MapWrapper {

    public MapKeyUpperWrapper(MetaObject metaObject, Map<String, Object> map) {
        super(metaObject, map);
    }

    @Override
    public String findProperty(String name, boolean useCamelCaseMapping) {
        if(useCamelCaseMapping){
            return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,name);
        }
        return name == null ? "" : name.toLowerCase();
    }

}